#!/bin/bash

case "$1" in
  114)
    DNS=114.114.114.114
    ;;
  ali)
    DNS=223.5.5.5
    ;;
  baidu)
    DNS=180.76.76.76
    ;;
  cnnic)
    DNS=1.2.4.8
    ;;
  dnspod)
    DNS=119.29.29.29
    ;;
  google)
    DNS=8.8.8.8
    ;;
  *)
    DNS=$1
esac

sed -i "s|^\(server.*\)/[^/]*$|\1/$DNS|" /etc/dnsmasq.d/accelerated-domains.china.conf
sed -i "s|^\(server.*\)/[^/]*$|\1/$DNS|" /etc/dnsmasq.d/google.china.conf 2>/dev/null
sed -i "s|^\(server.*\)/[^/]*$|\1/$DNS|" /etc/dnsmasq.d/apple.china.conf 2>/dev/null
